var api = require('../../utils/api.js')

Page({
    data: {
    },
    onLoad() {

    },
    onShow() {
        var that=this;

        wx.login({
            success: function (ret) {
                console.log(ret);
                wx.getUserInfo({
                    success: function () {
                        api.post({
                            url: 'wxapp/getopenid',
                            data: {'code':ret.code},
                            success: data => {
                                wx.setStorageSync('token', data.data.userinfo.token)
                                wx.setStorageSync('userinfo', data.data.userinfo)
                                wx.switchTab({
                                  url: '/pages/index/index',
                                })
                            }
                        })
                    }
                })
            }
        })
    },

});